#ifndef MY_SCENE_H
#define MY_SCENE_H

#include <stdio.h>	//for sprintf 

#include "../WinDraw/WinDraw.h"


#include "Background.h"
#include "CollectableItemsList.h"
#include "Character.h"
#include "PacMan.h"
#include "Ghost.h"
#include "CollisionManager.h"

class InputController;
class CollisionManager;

enum endGame{
	NOT_ENDED = 0,
	GAME_OVER,
	WON,
	LOST
};

class MyScene
{
private:
	Background*				mBg;
	CollectableItemsList*	mCandiesList;
	Character**				mCharacterList;//[NUM_CHARACTERS]
	PacMan*					mPlayer;
	InputController*		mInputCtrl;
	CollisionManager*		mCollisionMgr;

	static int counter;
	int mSpecialRemain;
	int mRemainCandies;
	endGame mEndGame;

	const int DRAW_PER_LOGIC_STEP;
	const int NUM_GHOST;
	const int NUM_CHARACTERS;
	const int START_POSITION;
	const int START_POS_ENEMIES;
	const int LOOPS_SPECIAL;

	void setupComponents() const;
	void setupCharCoord(const int startIndex, Character* nChar, const bool inactive = false) const;
	void setupCharsCoord() const;
	void setupCharsCoord(const int centralIndex, const bool inactive = false) const;
	void setupCandiesCoord() const;
	void setupCollisionMgr() const;

	void setCharacterPosition(Character* nChar, const int nTileIndex, BackgroundElement* nTile) const;

	void scoreToString(Character* nChar, char* oStr) const;

public:
	MyScene(void);
	~MyScene(void);

	const bool	  isGameEnded()		const { return mEndGame != NOT_ENDED;} 
	const bool	  isSpecialActive()	const { return mSpecialRemain > 0;	 }	
	const endGame getGameState()	const { return mEndGame;			 }
	const int stageWidth()  const;
	const int stageHeigth() const;
	/*void attach(InputController* inputCtrl);
	void detach();*/
	void setToSpecial();
	void decrementRemainCandies() { --mRemainCandies; }

	void DrawTo(Bitmap* renderTarget, const int x = 0, const int y = 0) const;
	void keyInput(const unsigned int Key, const KeyStatus status);
	void updateLogic();

};

#endif //MY_SCENE_H
